<template>
  <div>
    <div class="header">
      <div class="inputItem">
        <div class="title">意见内容</div>
        <div class="inputBox">
          <el-input v-model="entryName" @keyup.enter.native="searchList">
          </el-input>
        </div>
      </div>

      <!-- 查询 -->
      <div class="Btn_grounp">
        <el-button class="searchBtn" type="primary" size="small" icon="el-icon-search" @click="searchList">查询</el-button>
        <el-button class="clearBtn" type="plain" size="small" icon="el-icon-refresh-right" @click="CleanUp">清空</el-button>
      </div>
    </div>
    <div class="main">
      <div class="list">
        <el-table :data="records" style="width: 100%" ref="table">
          <el-table-column align="center" prop="" label="序号">
          </el-table-column>
          <el-table-column align="center" prop="transportStatus" label="状态">
            <template slot-scope="scope">
              <div class="tag">
                <div class="dian"></div>
                <div class="text">待处理</div>
              </div>
              <div class="tag gery">
                <div class="dian" style="color: #abb3b9"></div>
                <div class="text">已处理</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="" label="意见内容">
          </el-table-column>
          <el-table-column align="center" prop="" label="图片/视频">
            <template slot-scope="scope">
              <div>
                <img src="" alt="" />
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="" label="来源">
          </el-table-column>
          <el-table-column align="center" prop="" label="提交人">
          </el-table-column>
          <el-table-column align="center" prop="" label="提交时间">
          </el-table-column>
          <el-table-column align="center" prop="" label="样式信息">
          </el-table-column>

          <el-table-column align="center" label="操作">
            <template slot-scope="scope">
              <div>
                <el-button type="text" size="small" @click="
                  $router.push('/orderManagement/WaybillManagement/Details/')
                  ">标记为已处理</el-button>
                <!-- WaybillManagement/Details/:waybillId -->
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!-- 分页 -->
      <div class="paginationBox">
        <el-pagination class="pagination" background layout="slot,prev, pager, next" :total="data.total * 1"
          :page-size="data.size * 1" :pager-count="5" @current-change="changePages($event)">
          <template slot>
            <span style="
                color: #686868;
                font-size: 12px;
                margin-right: 20px;
                display: inline-block;
              ">共{{ data.total || '0' }}条,每页{{ data.size || '0' }}条</span>
          </template>
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import httpApi from "@/http";
export default {
  data() {
    return {
      WaybillStatus: "", //运单状态
      BusinessTypeValue: "", //业务类型
      WaybillNumber: "", //运单编号
      entryName: "", //项目名称
      TypeSelected: "",
      records: [],
      data: {},
      pageCurrent: "1",
      size: "1",
      //全部状态选项
      WaybillStatusArr: [
        { value: "3", label: "等待付款" },
        { value: "4", label: "已付款" },
        { value: "5", label: "发货中" },
        { value: "6", label: "已发货" },
        { value: "7", label: "等待到付" },
        { value: "8", label: "待签收" },
        { value: "9", label: "等待签收回单" },
        { value: "10", label: "已签收" },
      ],
      //   业务类型选项
      BusinessTypeArr: [
        { value: "1", label: "无需配送" },
        { value: "2", label: "未发货" },
        { value: "3", label: "部分发货" },
        { value: "4", label: "已发货" },
        { value: "5", label: "待装运" },
        { value: "6", label: "装运完成" },
        { value: "7", label: "运输中" },
        { value: "8", label: "已送达" },
        { value: "9", label: "完成卸货" },
      ],
    };
  },
  methods: {
    changePages(val) {
      this.pageCurrent = val;
      this.initList();
    },
    initList() {
      // status判定 2:已完成运单, 1:在途运单, 0:待审核运单
      let params = {
        orderStatus: "1",
        current: this.pageCurrent,
        size: this.size,
      };
      // httpApi.WaybillManagementApi.getWaybillList(params).then((res) => {
      //   // console.log(res);
      //   this.data = res.data.data;
      //   this.records = res.data.data.records;
      //   // console.log("总数据", this.data);
      //   // console.log("列表数据", this.records);
      // });
    },
    searchHttpList() {
      let params = {
        orderStatus: "1",
        current: this.pageCurrent,
        size: this.size,
        transportstatus: this.WaybillStatus,
        waybiliNo: this.WaybillNumber,
        orderType: BusinessTypeValue,
        projectName: this.entryName,
      };
      // httpApi.WaybillManagementApi.getWaybillList(params).then((res) => {
      //   // console.log(res);
      //   this.data = res.data.data;
      //   this.records = res.data.data.records;
      //   // console.log("搜索总数据", this.data);
      //   // console.log("搜索列表数据", this.records);
      // });
    },
    searchList() {
		this.pageCurrent=1;
      this.searchHttpList();
    },
    CleanUp() {
		this.entryName=""
		this.searchHttpList();
	 },
    // 记录滚动距离
    scrollEvent(res) {
      this.$route.meta.scrollTop = res.target.scrollTop
    },
  },
  mounted() {
    this.initList();
  },
  activated() {
    //组件激活时监听表格滚动条位置,
    this.$refs.table.bodyWrapper.addEventListener('scroll', this.scrollEvent, false)
    // 激活设置滚动位置
    this.$refs.table.bodyWrapper.scrollTop = this.$route.meta.scrollTop
  },
  beforeRouteLeave(to, from, next) {
    // 为了节省资源，再离开页面的时候关闭对于scroll事件的监听
    this.$refs.table.bodyWrapper.removeEventListener('scroll', this.scrollEvent)
    next()
  },


};
</script>

<style lang="scss" scoped>
.header {
  height: 76px;
  width: 100%;
  background-color: #fff;
  display: flex;
  align-items: center;
  padding: 0 29px;
  margin-bottom: 8px;

  .Btn_grounp {
    display: flex;

    .searchBtn {
      width: 80px;
      height: 32px;
      color: #fff;
      font-size: 12px;
    }

    .clearBtn {
      width: 80px;
      height: 32px;
      color: #262626;
      font-size: 12px;
    }
  }

  .inputItem {
    display: flex;
    align-items: center;
    margin-right: 23px;

    >.title {
      color: #262626;
      font-size: 12px;
      margin-right: 7px;
    }

    >.inputBox {
      width: 160px;

      .select {
        ::v-deep .el-input__icon {
          line-height: 0;
        }
      }

      ::v-deep .el-input__inner {
        height: 32px;
        font-size: 12px;
      }

      ::v-deep .el-input__inner::placeholder {
        color: #c3c3c3;
        font-size: 12px;
      }
    }
  }
}

.main {
  width: 100%;
  height: calc(100vh - 180px);
  background-color: #fff;
  padding: 30px 30px 0px 30px;

  .list {
    height: calc(100% - 48px);
    width: 100%;

    .tag {
      width: 63px;
      height: 28px;
      font-size: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 4px;
      background-color: #ecf5fe;
      color: #1890ff;

      .dian {
        width: 4px;
        height: 4px;
        border-radius: 50%;
        margin-right: 4px;
        color: #1890ff;
      }

      &.gery {
        background-color: #f6f7f8;
        color: #abb3b9;
      }
    }

    ::v-deep .el-table__body-wrapper {
      height: calc(100vh - 305px);
      overflow-y: scroll;
    }

    // 表头样式
    ::v-deep .el-table__header th {
      background-color: #f0f6fd;
      color: #262626;
      font-size: 12px;
      font-weight: bold;
      text-align: center;

      // 表 body的td
      ::v-deep .el-table__body td {
        color: #595959;
        font-size: 12px;
      }
    }

    .stateBtns {
      height: 30px;
      width: 76px;

      ::v-deep .el-button {
        height: 30px;
        width: 76px;
        font-size: 12px;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 30px;
      }

      .waitPass {
        background-color: #ecf5fe;
        color: #1890ff;
      }

      .noPass {
        background-color: #fde8e9;
        color: #f7555d;
      }
    }
  }

  .paginationBox {
    width: 100%;
    background-color: #fff;
    display: flex;
    align-items: center;
    height: 48px;


    .pagination {
      margin-left: auto;
      margin-right: 30px;
    }
  }
}
</style>
